Skip to content

Isolated dashboard app JavaScript #2155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

adamzap
Copy link
Member

@adamzap adamzap commented Aug 9, 2025

This patch moves the dashboard app's JavaScript inclusion from the project's require.js structure to the app itself.

This was achieved with a new block in the base template called javascript. The rest of the site gets the default JavaScript includes, and the dashboard app overrides the block to include the JavaScript specific to it. The dashboard app benefits by not knowing about JavaScript related to the rest of the site and vice versa.

None of the actual dashboard JavaScript code was changed. It was only adapted to the new structure.

  • Added javascript block to base template
  • Added dashboard_javascript block to dashboard base template
  • Included dashboard JavaScript directly in dashboard templates
  • Removed dashboard-related entries in main.js
  • Remove references to jquery.flot.min.js from base template
    • This library is only used by the dashboard app
  • Removed dashboard-* CSS classes only used by require.js
  • Removed require.js structure in dashboard JavaScript files
  • Simplified structure of utils.js

This patch moves the `dashboard` app's JavaScript inclusion from the
project's `require.js` structure to the app itself.

This was achieved with a new block in the base template called
`javascript`. The rest of the site gets the default JavaScript includes,
and the `dashboard` app overrides the block to include the JavaScript
specific to it. The `dashboard` app benefits by not knowing about
JavaScript related to the rest of the site and vice versa.

None of the actual `dashboard` JavaScript code was changed. It was only
adapted to the new structure.

- Added `javascript` block to base template
- Added `dashboard_javascript` block to `dashboard` base template
- Included `dashboard` JavaScript directly in `dashboard` templates
- Removed `dashboard`-related entries in `main.js`
- Remove references to `jquery.flot.min.js` from base template
  - This library is only used by the `dashboard` app
- Removed `dashboard-*` CSS classes only used by `require.js`
- Removed `require.js` structure in `dashboard` JavaScript files
- Simplified structure of `utils.js`
{% block body_extra %}{% endblock body_extra %}
<script src="{% static "js/djangoproject.js" %}"></script>

{% block javascript %}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The addition of this block is probably the most controversial change in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant